#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"autho.h"
#include <unistd.h>

       char *getpass( const char *prompt);


/*void ajouter(char log[],char chemin3[])
{
FILE *f2;
f2=fopen(chemin3,"w");
if(f2!=NULL)
{
printf("Bienvenue Cher utilisateur\n");

printf("donner le login\n");
scanf("%s",log);

fputs(log,f2);
}
fclose(f2);
} */



void rechercher(char chemin2[],char mdp[],char chemin3[],char log[]) 
{
FILE *f;
FILE *f2;
char mot[20],mdpfile[20];
char name[30] ;
f=fopen(chemin2,"r");
f2=fopen(chemin3,"r");
if(f==NULL){return;}
rewind(f);
fgets(mdpfile,20,f);
if(f2==NULL){return;}
rewind(f2);
fgets(log,30,f2);
	do {
		printf("LOGIN: \n");
		scanf("%s",name);
   	    } while(strcmp(name,log)!=0) ;
do {
strcpy(mot,getpass("\nVeuillez taper votre Mot de Passe  \n"));
}while (strcmp(mot,mdpfile)!=0) ;
//if ((strcmp(mot,mdpfile)==0)&&(strcmp(name,log)==0)) 
//{printf("authentification correcte \n");}
printf("\n   *** Bienvenue ***");
}

void autho()
{char mdp[10];
char log[30];
    //ajouter(log,"chemin3.txt");
    rechercher("chemin2.txt",mdp,"chemin3.txt",log);
}



